home *** CD-ROM | disk | FTP | other *** search
- class Class.Bullet extends MovieClip
- {
- var Vg;
- var V_jumpY;
- var opp;
- var startX;
- var x;
- var startY;
- var y;
- var landY;
- var onEnterFrame;
- var Vx;
- var Vy;
- var area;
- var timer_bounce;
- var mc;
- var inHit = false;
- var inHitObj = false;
- var inStop = false;
- function Bullet()
- {
- super();
- this.Vg = _root.Vg;
- this.V_jumpY = -5;
- }
- function init(_opp)
- {
- this.opp = _opp;
- }
- function reset()
- {
- this._visible = false;
- this.inHit = false;
- this.inHitObj = false;
- this.inStop = false;
- }
- function jump1()
- {
- this.startX = this.x;
- this.startY = this.y;
- this.play();
- }
- function jump2()
- {
- this.landY = _root.mc.role.y + 10;
- this.onEnterFrame = function()
- {
- this.y += this.V_jumpY;
- _root.mc.make3D(this);
- this.V_jumpY += this.Vg;
- if(this.y >= _root.mc.role.y + 10)
- {
- this.y = _root.mc.role.y + 10;
- delete this.onEnterFrame;
- }
- };
- }
- function hitAway(_Vx, _Vy, countDis)
- {
- trace("hitAway: " + _Vx + " " + _Vy);
- this._visible = true;
- this.Vx = _Vx;
- this.Vy = _Vy;
- var _loc5_ = ExtMath.atan2D(this.Vy,this.Vx);
- this._rotation = _loc5_;
- var _loc4_ = _root.playControl.wind_lv;
- var _loc3_ = _loc4_ * 5;
- §§push(this.gotoAndPlay("fly"));
- if(isNaN(_loc3_))
- {
- _loc3_ = 0;
- }
- if(_loc3_ != 0)
- {
- this.Vx += _loc3_;
- }
- var dis = 0;
- this.onEnterFrame = function()
- {
- this.x += this.Vx;
- dis += this.Vx;
- if(countDis != false)
- {
- _root.UI_mc.setDistance(int(Math.abs(dis) * 25) / 100);
- }
- this.y += this.Vy;
- this.Vy += this.Vg;
- _root.mc.make3D(this);
- if(this.checkHit())
- {
- return undefined;
- }
- if(this.y >= _root.mc.role.y)
- {
- this.y = _root.mc.role.y;
- delete this.onEnterFrame;
- this.stick();
- }
- };
- }
- function bounceAway(_Vx, _Vy)
- {
- this._visible = true;
- this.Vx = _Vx;
- this.Vy = _Vy;
- var _loc5_ = ExtMath.atan2D(this.Vy,this.Vx);
- this._rotation = _loc5_;
- var _loc4_ = _root.playControl.wind_lv;
- var _loc3_ = _loc4_ * 5;
- §§push(this.gotoAndPlay("fly"));
- if(isNaN(_loc3_))
- {
- _loc3_ = 0;
- }
- if(_loc3_ != 0)
- {
- this.Vx += _loc3_;
- }
- var dis = 0;
- this.onEnterFrame = function()
- {
- this.x += this.Vx;
- dis += this.Vx;
- this.y += this.Vy;
- this.Vy += this.Vg;
- _root.mc.make3D(this);
- if(this.y >= _root.mc.role.y)
- {
- this.y = _root.mc.role.y;
- delete this.onEnterFrame;
- this.stick();
- }
- };
- }
- function checkHit()
- {
- if(this.inHit)
- {
- return undefined;
- }
- if(this.inStop)
- {
- return undefined;
- }
- var _loc5_ = _global.lToG(this.area);
- var _loc4_ = this.opp.area.getBounds(_root);
- if(_loc5_.x > _loc4_.xMin && _loc5_.x < _loc4_.xMax + this.Vx && _loc5_.y > _loc4_.yMin && this.Vx > 0)
- {
- this.hit();
- return true;
- }
- if(_loc5_.x > _loc4_.xMin + this.Vx && _loc5_.x < _loc4_.xMax && _loc5_.y > _loc4_.yMin && this.Vx < 0)
- {
- this.hit();
- return true;
- }
- if(_root.mc.iceHill instanceof MovieClip)
- {
- this.hit_obj(_root.mc.iceHill);
- }
- }
- function hit()
- {
- this.inHit = true;
- var _loc4_ = _global.lToG(this);
- var _loc5_ = 200;
- if(this.opp.area1.hitTest(_loc4_.x,_loc4_.y,true))
- {
- this.opp.hit(1,1);
- var _loc6_ = this.Vx / 3;
- if(Math.abs(_loc6_) > 30)
- {
- _loc6_ = this.Vx / 5;
- }
- this.timer_bounce = setInterval(this,"bounce",_loc5_,_loc6_,(- this.Vy) / 2);
- _root.playControl.onHit("great");
- }
- else if(this.opp.area2.hitTest(_loc4_.x,_loc4_.y,true))
- {
- this.opp.hit(2,0.7);
- _loc6_ = (- this.Vx) / 3;
- if(Math.abs(_loc6_) > 30)
- {
- _loc6_ = (- this.Vx) / 5;
- }
- this.timer_bounce = setInterval(this,"bounce",_loc5_,_loc6_,(- this.Vy) / 2);
- _root.playControl.onHit("great");
- }
- else if(this.opp.area3.hitTest(_loc4_.x,_loc4_.y,true))
- {
- this.opp.hit(3,0.5);
- _loc6_ = (- this.Vx) / 3;
- if(Math.abs(_loc6_) > 30)
- {
- _loc6_ = (- this.Vx) / 5;
- }
- this.timer_bounce = setInterval(this,"bounce",_loc5_,_loc6_,(- this.Vy) / 2);
- _root.playControl.onHit("good");
- }
- else if(this.opp.area4.hitTest(_loc4_.x,_loc4_.y,true))
- {
- this.opp.hit(4,0.5);
- _loc6_ = this.Vx / 3;
- if(Math.abs(_loc6_) > 30)
- {
- _loc6_ = this.Vx / 5;
- }
- this.timer_bounce = setInterval(this,"bounce",_loc5_,_loc6_,(- this.Vy) / 2);
- _root.playControl.onHit("good");
- }
- else if(this.opp.area5.hitTest(_loc4_.x,_loc4_.y,true))
- {
- this.opp.hit(5,0.3);
- _loc6_ = (- this.Vx) / 3;
- if(Math.abs(_loc6_) > 30)
- {
- _loc6_ = (- this.Vx) / 5;
- }
- this.timer_bounce = setInterval(this,"bounce",_loc5_,_loc6_,(- this.Vy) / 6);
- _root.playControl.onHit("good");
- }
- else
- {
- this.opp.hit(4,0.5);
- _loc6_ = this.Vx / 3;
- if(Math.abs(_loc6_) > 30)
- {
- _loc6_ = this.Vx / 5;
- }
- this.timer_bounce = setInterval(this,"bounce",_loc5_,_loc6_,(- this.Vy) / 2);
- _root.playControl.onHit("good");
- }
- delete this.onEnterFrame;
- this.mc.stop();
- }
- function hit_obj(mc)
- {
- if(this.inHitObj)
- {
- return undefined;
- }
- var _loc4_ = _global.lToG(this);
- var _loc6_ = 50;
- if(mc.area1.hitTest(_loc4_.x,_loc4_.y,true))
- {
- this.inHitObj = true;
- trace("hit_obj11111: ");
- mc.hit(1,1);
- _root.soundStart("balloon_snd");
- this.timer_bounce = setInterval(this,"bounce",_loc6_,this.Vx / 3,(- this.Vy) / 2);
- delete this.onEnterFrame;
- this.mc.stop();
- }
- else if(mc.area2.hitTest(_loc4_.x,_loc4_.y,true))
- {
- this.inHitObj = true;
- trace("hit_obj22222: ");
- mc.hit(1,1);
- _root.soundStart("balloon_snd");
- this.timer_bounce = setInterval(this,"bounce",_loc6_,(- this.Vx) / 3,(- this.Vy) / 2);
- delete this.onEnterFrame;
- this.mc.stop();
- }
- }
- function bounce(bounceVx, bounceVy)
- {
- clearInterval(this.timer_bounce);
- this.mc.play();
- this.bounceAway(bounceVx,bounceVy);
- }
- function stick()
- {
- this.moveStop();
- }
- function slide(_Vx)
- {
- this.Vx = _Vx;
- this.onEnterFrame = function()
- {
- this.x += this.Vx;
- this.Vx *= 0.9;
- _root.mc.make3D(this);
- if(this.Vx < 1)
- {
- delete this.onEnterFrame;
- this.moveStop();
- }
- };
- }
- function moveStop()
- {
- this.inStop = true;
- _root.mc.addObj("bulletStick",this.x,this.y + 20,3 + int(Math.random() * 3));
- this._visible = false;
- this.gotoAndStop(1);
- if(this.inHit != true)
- {
- _root.playControl.onMiss();
- }
- else
- {
- _root.playControl.onShootEnd();
- }
- _root.soundStart("hit2_snd");
- delete this.onEnterFrame;
- }
- function onUnload()
- {
- clearInterval(this.timer_bounce);
- }
- }
-